/**
 * @author Daniel Monteiro
 * */

package libTease.demos.android.gles10;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.opengl.GLSurfaceView;
import android.opengl.GLU;

public class LibTeaseGLES10DemoRenderer implements GLSurfaceView.Renderer
{

	// ------------------------------------------------------------------------------------------------------------
	public LibTeaseGLES10DemoRenderer()
	{
	}

	// ------------------------------------------------------------------------------------------------------------
	public void onSurfaceCreated(GL10 gl, EGLConfig config)
	{
		gl.glShadeModel(GL10.GL_FLAT);
		gl.glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
		gl.glClearDepthf(1.0f);
		gl.glEnable(GL10.GL_DEPTH_TEST);
		gl.glDepthFunc(GL10.GL_LEQUAL);
		gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
	}

	// ------------------------------------------------------------------------------------------------------------

	// ------------------------------------------------------------------------------------------------------------
	public void renderScene(GL10 gl)
	{
	}

	// ------------------------------------------------------------------------------------------------------------
	public void onDrawFrame(GL10 gl)
	{
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
		gl.glLoadIdentity();

	}


	// ------------------------------------------------------------------------------------------------------------
	public void onSurfaceChanged(GL10 gl, int width, int height)
	{
		if (height == 0)
		{
			height = 1;
		}

		gl.glViewport(0, 0, width, height);
		gl.glMatrixMode(GL10.GL_PROJECTION);
		gl.glLoadIdentity();

		GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f,
				255.0f);

		gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();
	}

}
